package com.atguigu.tingshu.user.config.rabbitMQ;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 账户初始化RabbitMQ配置
 * @author Haoran Sun
 * @since 2024/08/17
 */

@Configuration
public class UserAccountInitRabbitConfig {

    @Bean
    public Exchange accountExchange(){
        return ExchangeBuilder
                .directExchange("account_exchange")
                .build();
    }

    @Bean
    public Queue accountQueue(){
        return QueueBuilder
                .durable("account_queue")
                .build();
    }

    @Bean
    public Binding accountBinding(
            @Qualifier("accountExchange") Exchange accountExchange,
            @Qualifier("accountQueue") Queue accountQueue
    ){
        return BindingBuilder
                .bind(accountQueue)
                .to(accountExchange)
                .with("user_account_init")
                .noargs();
    }




}
